def prostoe_ly(x):
  a=True
  for i in range(2, x):
      if x % i == 0:
          a=False
  return a
b = input()
h = 0
h1 = 0
p=[]
p1=[]
SS=b.split()
w = False
number=' '
k = [2,number]
for i in SS:
  if len(SS) == 3:  
    if i == 'zero':
      number = str(number) + '0'
    if i == 'one':
      number = str(number) + '1'
    if i == 'two':
      number = str(number) + '2'
    if i == 'three':
      number = str(number) + '3'
    if i == 'four':
      number = str(number) + '4'
    if i == 'five':
      number = str(number) + '5'
    if i == 'six':
      number = str(number) + '6'
    if i == 'seven':
      number = str(number) + '7'
    if i == 'eight':
      number = str(number) + '8'
    if i == 'nine':
      number = str(number) + '9'
    number=int(number)
    for y in range(number+1,number+100):
      a=prostoe_ly(y)
      if a==True:
          p.append(y)
    for q in range(1,number):
      a=prostoe_ly(q)
      if a==True:
          p1.append(q)
  else:
    w = True
  if w == True:
    print('Wrong input')
if (number-p1[-1])>(p[0]-number):
  print(p[0])
else:
  print(p1[-1])
  print(number)